package com.itheima.mobile.mapper;

import com.itheima.mobile.pojo.Member;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

public interface MemberDao {

    @Select("select * from t_member where phoneNumber = #{phone}")
    Member getMemberByPhone(String phone);

    @Insert("insert into t_member values(null,null,#{name},#{sex},#{idCard},#{phoneNumber},#{regTime},null,null,null,null)")
    @SelectKey(statement = "select last_insert_id() from dual", before = false,
            resultType = Integer.class, keyColumn = "id", keyProperty = "id"
    )
    int add(Member member);

    @Select("select * from t_member where id = #{memberId}")
    Member getById(String memberId);
}
